
use fltk::{app, button::Button, frame::Frame, group::Flex, prelude::*, table, window::Window};
use fltk::enums::{Align, Event};
use fltk::table::TableContext;

fn tt(col: &mut Flex) {

        let mut frame = Frame::default();
        let mut but = Button::default().with_label("Click me!");
        col.fixed(&but, 40);
        // but.set_callback(move | b  | {
        //         println!("Clicked cell: Row {}, Column {}", "xx", "xx");
        //         frame.set_label("Hello world");
        //         b.set_label("ewrw");
        // });
        col.end();



        let mut table = table::Table::default()
            .with_size(400, 300)
            ;

        table.set_cols(3);
        table.set_rows(3);
        table.draw_cell(move |_table, ctx, row, col, x, y, w, h| {
                fltk::draw::draw_text2("12313", x, y, w, h, Align::Center);

        });
        table.set_callback(move |tb | {
                println!("Clicked cell: Row {}, Column {}", tb.callback_row(), tb.callback_col());
                frame.set_label("Hello world");
                but.set_label("vvv")
        });

        // table.handle(move |tb, ev| {
        //         but.set_label("vvv");
        //         true
        // });
        table.end();




}

#[test]
fn test_windows() {

        let app = app::App::default();
        let mut wind = Window::default().with_size(400, 300);
        let mut col = Flex::default_fill().column();
        col.set_margins(120, 80, 120, 80);
        tt(&mut col);
        wind.end();
        wind.show();



        app.run().unwrap();

}